import { getFormatterPrice, formatDate } from '@const/filter'

// 列表--搜索字段
export const indexSearchData = [
  {
    key: 'hospitalName',
    title: '医疗机构',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxLength: 98
    }
  },
  {
    key: 'startTime',
    title: '创建时间',
    type: 'time',
    fieldname: ['beginDate', 'endDate'],
    attr: {
      style: 'width:270px !important;',
      class: 'daterange',
      type: 'daterange',
      'start-placeholder': '开始时间',
      'end-placeholder': '结束时间',
      'default-time': ['00:00:00', '23:59:59']
    }
  }
]
// 列表--列表表头
export const indexTableData = [
  { type: 'index', label: '序号', width: 56 },
  { prop: 'tradeOrderCode', label: '收款单号', 'min-width': 170, 'show-overflow-tooltip': true },
  { prop: 'hospitalName', label: '付款方名称', 'min-width': 170, 'show-overflow-tooltip': true },
  // {
  //   prop: 'invoiceAmount',
  //   label: '关联产品金额（元）',
  //   width: 170,
  //   'show-overflow-tooltip': true,
  //   formatter: row => {
  //     if (row.invoiceAmount) {
  //       return getFormatterPrice(row.invoiceAmount)
  //     }
  //   }
  // },
  // { prop: 'invoiceCount', label: '发票数', width: 170 },
  {
    prop: 'invoiceAmount',
    label: '总金额（元）',
    width: 170,
    formatter: row => {
      if (row.invoiceAmount) {
        return getFormatterPrice(row.invoiceAmount)
      }
    }
  },
  { prop: 'invoiceCount', label: '关联发票数', width: 170 },
  { prop: 'createdAt', label: '创建时间', width: 150 },
  {
    prop: 'tradeOrderStatusName',
    label: '状态',
    width: 100
    // formatter: row => {
    //   return statusArr[row.orderStatus]
    // }
  },
  { prop: 'action', label: '操作', width: 120, fixed: 'right' }
]

// 列表页-tab
// 开票订单状态（1-待月结；2-已月结；3-已验票；4-已撤销）
export const indexTabsArr = [
  { lab: '待收款', val: 1, badge: { value: null } },
  { lab: '部分收款', val: 4, badge: { value: null } },
  { lab: '已完结', val: 5, badge: { value: null } },
  { lab: '已撤销', val: 3, badge: { value: null } },
  { lab: '全部', val: 0, badge: { value: null } }
]
// 开票订单状态（1-待开票；2-已推送；3-已开票；4-验票完成；5-已撤销）
export const statusArr = {
  0: '全部',
  1: '待收款',
  // 2: '已推送',
  3: '已撤销',
  4: '部分收款',
  5: '已完结'
}
// 产品大类
export const categoryArr = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '器械'
}
// 详情 - 收款记录
export const collectionColumns = [
  {
    prop: 'tradeAmount',
    label: '收款金额（元）',
    'min-width': 150,
    formatter: row => {
      if (row.tradeAmount) {
        return getFormatterPrice(row.tradeAmount)
      }
    }
  },
  {
    prop: 'surplusAmount',
    label: '剩余收款金额（元）',
    'min-width': 150,
    formatter: row => {
      if (row.surplusAmount) {
        return getFormatterPrice(row.surplusAmount)
      } else {
        return 0
      }
    }
  },
  { prop: 'tradeTime', label: '收款时间', 'min-width': 150 },
  { prop: 'tradeBy', label: '收款人', 'min-width': 150 },
  { prop: 'remarks', label: '备注', 'min-width': 150 }
]
// 详情/收款 - 发票
export const invoiceColumns = [
  // { type: 'selection', label: '发票影像', 'min-width': 150 },
  { prop: 'invoiceUrl', label: '发票影像', width: 80 },
  { prop: 'invoiceDetail', label: '发票清单', width: 80 },
  { prop: 'invoiceNo', label: '发票号码', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'invoiceKindName', label: '发票类型', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'invoiceCode', label: '发票代码', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'invoiceDate', label: '开票日期', 'min-width': 150, 'show-overflow-tooltip': true },
  {
    prop: 'totalPriceTax',
    label: '价税合计',
    'min-width': 150,
    'show-overflow-tooltip': true,
    formatter: row => {
      if (row.totalPriceTax) {
        return getFormatterPrice(row.totalPriceTax)
      }
    }
  },
  // { prop: 'totalTax', label: '税率', 'min-width': 150, 'show-overflow-tooltip': true },
  {
    prop: 'totalTax',
    label: '税额',
    'min-width': 150,
    'show-overflow-tooltip': true,
    formatter: row => {
      if (row.totalTax) {
        return getFormatterPrice(row.totalTax)
      }
    }
  },
  {
    prop: 'amountNoTax',
    label: '发票金额',
    'min-width': 150,
    'show-overflow-tooltip': true,
    formatter: row => {
      if (row.amountNoTax) {
        return getFormatterPrice(row.amountNoTax)
      }
    }
  },
  { prop: 'checkCode', label: '校验码', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'saleCompany', label: '销售方', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'saleRegistrationCode', label: '销售方纳税人识别号', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'buyCompany', label: '采购方', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'buyRegistrationCode', label: '采购方纳税人识别号', 'min-width': 150, 'show-overflow-tooltip': true },
  { prop: 'remark', label: '备注', 'min-width': 150, 'show-overflow-tooltip': true }
]
// 详情 - 收款明细
export const collectionDetailsListColunmns = [
  { prop: 'pssProdCode', label: '产品编码', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdName', label: '产品名称', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdSpec', label: '规格', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdModel', label: '型号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssMinUnit', label: '单位', width: 90 },
  {
    prop: 'prodPrice',
    label: '单价（元）',
    width: 150,
    formatter: row => {
      if (row.prodPrice) {
        return getFormatterPrice(row.prodPrice)
      }
    }
  },
  { prop: 'udi', label: 'UDI', width: 150, 'show-overflow-tooltip': true },
  { prop: 'serialNo', label: '主码', width: 150, 'show-overflow-tooltip': true },
  { prop: 'productBatch', label: '批号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'num', label: '数量', width: 100 },
  { prop: 'pssRegistNo', label: '注册证号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdManufacturer', label: '生产厂家', width: 150, 'show-overflow-tooltip': true },
  {
    prop: 'detailAmount',
    label: '小计金额（元）',
    width: 130,
    'show-overflow-tooltip': true,
    formatter: row => {
      if (row.detailAmount) {
        return getFormatterPrice(row.detailAmount)
      }
    }
  },
  { prop: 'supplierName', label: '供应商', width: 150, 'show-overflow-tooltip': true },
  {
    prop: 'taxRate',
    label: '税率',
    width: 90,
    formatter: row => {
      return row.taxRate || null
    }
  },
  {
    prop: 'tax',
    label: '税额',
    width: 90,
    formatter: row => {
      return row.tax || null
    }
  }
]
// 详情页-基本信息表头
export const nissinReadColunmns = [
  [
    { key: 'tradeOrderCode', label: '收款单号:' },
    { key: 'hospitalName', label: '付款方名称:' },
    { key: 'invoiceAmount', label: '金额合计（元）:' }
  ],
  [
    { key: 'invoiceCount', label: '关联发票数:' },
    { key: 'saleBankInfo', label: '付款方开户信息' },
    { key: 'createdAt', label: '创建时间:' }
  ]
]
// 详情页-基本信息表头
export const collectionDetailsColunmns = [
  [
    { key: 'invoiceName', label: '发票抬头:' },
    { key: 'invoiceCode', label: '发票代码:' },
    { key: 'invoiceNo', label: '发票编号:' }
  ],
  [
    { key: 'invoiceAmountTax', label: '发票金额（元）:' },
    { key: 'invoiceDate', label: '开票时间:' },
    { key: 'drawer', label: '开票人:' }
  ],
  [
    { key: 'invoiceComp', label: '开票企业:' }
  ]
]
